﻿#include <stdio.h>
#include <string.h>
#define N 10
struct user{
	char name[20];
	char password[20];
};
int  fun(struct user users[])
{
	int i=0,j,k;
	int n=N;
	while(i<n)
	{
	/**********found**********/
		j=i+1;
		while(j<n)
		{
			if(strcmp(users[i].name,users[j].name)==0)
				{
					k=j;
	/**********found**********/
					for(;k<n-1;k++)
	/**********found**********/
						users[k]=users[k+1];
					n--;
				}
			j++;
		}
		i++;
	}
	return n;
}
main()
{
	int i,n=N;
	struct user users[N]={{"zhang","skf"},{"li","kf123"},{"chen","df77dd"},{"zhang","tt186"},
					  {"ou","ou1236"},{"li","kk99qq"},{"sun","s9527"},{"guo","gg99"},
					  {"yu","qiqi11367"},{"li","ww8866"}};
	printf("删除用户记录中账号重复的记录之前：\n");
	for(i=0;i<n;i++)
		printf("%4d%20s%20s\n",i,users[i].name,users[i].password);
	printf("删除用户记录中账号重复的记录之后：\n");
	n=fun(users);
	for(i=0;i<n;i++)
		printf("%4d%20s%20s\n",i,users[i].name,users[i].password);
 }
